/**********************************************************

     文件名称: mv_cashier.c

     项目功能: 

     作者: 佳奇

     邮箱: 1374804492@qq.com 

     创建时间: Fri 26 Aug 2022 12:27:08 AM CST

**********************************************************/


#include <stdio.h>
#include <stdlib.h>
#include "sup_mgr.h"


//	通过工号修改员工信息
void mv_cas(cas_list* demo)
{
	int user;
	cas_list* s1 = demo;

	while(1)
	{
		demo = demo->next;

		system("clear");
		printf("\n请输入您要修改员工信息的工号:");
		while(!geshipanduan(scanf("%d", &user)));

		while(demo != NULL && demo->data->user != user)	demo = demo->next;

		if(demo == NULL)
		{
			printf("\n没有查询到此员工信息， 无法修改！\n");
			printf("是否继续执行修改操作(y/n):");
			c_buffer();
			if(getchar() != 'y')
			{
				c_buffer();
				return;
			}
			else
			{
				demo = s1;
				continue;
			}
		}
		else
		{
			printf("工号：%d 原始员工信息如下：\n", user);
			printf("\n工号：%d", demo->data->user);
			printf("\n姓名：%s", demo->data->name);
			printf("\n性别：%s", demo->data->sex == '1' ? "男" : "女");
			printf("\n电话：%s", demo->data->phone);
			printf("\n住址：%s", demo->data->add);
			printf("\n身份证号：%s", demo->data->id);
			printf("\n*********************\n");
			printf("即将更改为\n");
		
			while(1)
			{
				while(1)
				{
					printf("新工号：");
					if(!scanf("%d", &user))
					{
						c_buffer();
						fprintf(stderr, "格式输入错误，请重新输入\n");
					}
					else break;
				}

				//  判断工号是否已经存在
				if(deter(s1, user))
				{
					c_buffer();
					fprintf(stderr, "\n工号已经存在！请重新输入\n");
				}
				else    break;
			}
		
			demo->data->user = user;
			c_buffer();
			printf("\n新身份证号：");
			scanf("%18s", demo->data->id);
			c_buffer();
			printf("\n新姓名：");
			scanf("%30s", demo->data->name);
			c_buffer();
			printf("\n性别(0 为女 1 为男)：");
			scanf("%c", &demo->data->sex);
			c_buffer();
			printf("\n新电话号码：");
			scanf("%11s", demo->data->phone);
			c_buffer();
			printf("\n新住址：");
			scanf("%90s", demo->data->add);
			c_buffer();

			printf("%s 信息修改成功\n", demo->data->name);
			printf("是否继续修改(y/n):");
			if(getchar() != 'y')
			{
				c_buffer();
				return;
			}
			else
			{
				demo = s1;
				continue;
			}

		}

	}
}

